
// var url = 'http://47.108.197.28:3000/top/playlist/highquality'
// $(function () {
//     $ajax({
//         url,
//         success: res => {
//             var play = res.playlists;

//                 play.slice(0,9).forEach(item => {
//                     var { name, coverImgUrl, playCount } = item;
//                    var count =  Count(playCount)
//                     // console.log(count)
//                     var template = `
//                    <div class="content">
//                         <div><img src="${coverImgUrl}" alt=""></div>
//                         <div class = "play"><i class="iconfont">&#xea6d;</i>${count}</div>
//                         <div>${name}</div>
//                     </div>
//                    `
//                    $(".container").append(template)
//                 });

//         }
//     })
//     function Count(playCount){
//         if(playCount>10000){
//             playCount = Math.ceil(playCount/10000)+'万'
//         }
//         else if(playCount>100000000){
//             playCount = Math.floor(playCount/100000000)+'亿'
//         }
//         return playCount;
//     }
// })
$(function () {
    var url = 'http://47.108.197.28:3000/top/playlist/highquality'

    $ajax({
        url,
        success: res => {
            res.playlists.slice(0,9).forEach(item => {
                var { name, coverImgUrl, playCount } = item;
                var play = handlePlay(playCount)
                var template = `
                    <div class="content">
                        <div><img src="${coverImgUrl}" alt=""></div>
                        <div class = "play"><i class="iconfont">&#xea6d;</i>${play}</div>
                        <div>${name}</div>
                    </div>
                `
                $(".container").append(template)
            })
            function handlePlay(num){
                if(num>10000){
                    num = Math.ceil(num/10000) +"万"
                }
                if(num>100000000){
                    num = Math.floor(num/100000000) +"亿"
                }
                return num;
            }
        }
    })
})

